<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title site-title">
		<legend>
			<a name="fixbar" style="font-size: 16px; color: #ce2424;">学生注册审核</a>
		</legend>
	</fieldset>
	<form class="layui-form" id="myForm" method="post" lay-filter="stuform">
		<div class="layui-form-item">
			<div class="layui-inline" style="width: 350px;">
				<label class="layui-form-label">班级名称：</label>
				<div class="layui-input-block">
					<select id="bjid" lay-filter="bjselect" lay-verify="required"
						lay-search>
						<c:forEach var="d" items="${bjs}">
							<option value="${d.id}">${d.name}</option>
						</c:forEach>
					</select>
				</div>
			</div>
		</div>
	</form>
	<table id="stable" lay-filter="stable"></table>
	<div id="ju" style="display: none;">
		<form class="layui-form layui-form-pane">
			<div class="layui-form-item layui-form-text">
				<div class="layui-input-block">
					<textarea id="cause" placeholder="请输入原因"  class="layui-textarea"></textarea>
				</div>
			</div>
		</form>
	</div>
	<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="instant">一键同意</button>
  	</div>
</script>
	<script type="text/html" id="barDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="agree">同意</button>
		<button class="layui-btn layui-btn-sm" lay-event="repulse">拒绝</button>
  	</div>
</script>

	<script type="text/javascript">
	
	layui.use('form', function(){
		var form = layui.form;
		form.render('select');
		
		form.on('select(bjselect)', function(data) {
			var bjuuid = data.value;
			var id = $(this).attr("lay-value");
			layui.use('table', function() {
				var table = layui.table;
				table.reload('idTest', {
					url : 'student/page1',
					where : {
						bjuuid : bjuuid
					},
					page : {
						curr : 1
					//重新从第 1 页开始
					}
				});
			});
		});
	})
		layui.use('table', function() {
			var table = layui.table;
			var bjuuid = $("#bjid").val();
			table.render({
				elem : '#stable',
				url : 'student/page1',
				id : 'idTest',
				height : 'full-270',
				where : {
					bjuuid : bjuuid
				},
				toolbar : '#toolbarDemo',
				cols : [ [ {
					field : 'tbClass',
					title : '班级',
					templet : function(d) {
						return d.tbClass ? d.tbClass.name : '';
					}
				}, {
					field : 'name',
					title : '姓名'
				}, {
					field : 'username',
					title : '用户名'
				}, {
					field : 'sex',
					title : '性别'
				}, {
					field : 'idcode',
					hide : true,
					title : '身份证号'
				}, {
					field : 'nation',
					hide : true,
					title : '民族'
				}, {
					field : 'politics',
					hide : true,
					title : '政治面貌'
				}, {
					field : 'degree',
					hide : true,
					title : '文化程度'
				}, {
					field : 'bron',
					hide : true,
					title : '出生日期'
				}, {
					field : 'email',
					hide : true,
					title : '邮箱'
				}, {
					field : 'officetel',
					hide : true,
					title : '办公电话'
				}, {
					field : 'job',
					hide : true,
					title : '现任职务'
				}, {
					field : 'jobLevel',
					hide : true,
					title : '职级'
				}, {
					field : 'postalCode',
					hide : true,
					title : '邮政编码'
				}, {
					field : 'speciality',
					hide : true,
					title : '专业技术职称'
				}, {
					field : 'address',
					hide : true,
					title : '单位地址'
				}, {
					field : 'phone',
					title : '手机'
				}, {
					field : 'workUnit',
					hide : true,
					title : '工作单位'
				}, {
					field : 'groupNumber',
					hide : true,
					title : '组号'
				}, {
					field : 'siteNumber',
					hide : true,
					title : '座位号'
				}, {
					field : 'carnumber',
					hide : true,
					title : '车牌号'
				}, {
					field : 'position',
					hide : true,
					title : '班级职务'
				}, {
					fixed : 'right',
					title : '功能',
					align : 'center',
					toolbar : '#barDemo',
				} ] ],
				page : true
			});

			table.resize('idTest');

			//监听表头工具事件

			table.on('toolbar(stable)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				if (obj.event === "instant") {
					layer.confirm('确认一键同意？', function(index) {
						$.post('student/instant', function(data) {
							layer.msg(data);
							table.reload('idTest', {
								url : 'student/page1'
							});
						});
					});
				}
			});

			table.on('tool(stable)', function(obj) {
				var data = obj.data;
				if (obj.event === "agree") {
					if (data.id != null || data.id != ""){
						layer.confirm('确认同意？', function(index) {
							$.post('student/agree', {
								id : data.id
							}, function(data) {
								layer.msg(data);
								table.reload('idTest', {
									url : 'student/page1'
								});
							});

						});
					}else{
						layer.msg("未选中行喔！");
					}
						
				}
				if (obj.event === "repulse") {
					if (data.id != null || data.id != "") {
						layer.open({
							type : 1,
							shade : false,
							title:"拒绝原因",
							//shadeClose : true,
							anim : 5,
							content : $('#ju'),
							area : [ '400px', '240px' ],
							btn : [ '提交', '关闭' ],
							yes : function() {
								var reason = $("#cause").val();
								$.post('student/repulse', {
									id : data.id,
									yuanyi : reason
								}, function(data) {
									layer.msg(data);
									table.reload('idTest', {
										url : 'student/page1'
									});
								});
								layer.closeAll('page');
							},
							btn2 : function() {
								layer.closeAll('page');
							}
						});
					} else {
						layer.msg("未选中行喔！");
					}
						
				}
			});
		});
	</script>
</body>
</html>